﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using T4Ui.dal;
namespace T4Ui
{
    public partial class ColumnFrm : Form
    {
        public ColumnFrm()
        {
            InitializeComponent();
        }

        private static log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public Table EditData;
        public List<Column> SelectData;
        private void btnOk_Click(object sender, EventArgs e)
        {
            SelectData = new List<Column>();
            Column tmp = null;
            foreach (DataGridViewRow drv in dgvMain.Rows)
            {
                tmp = (Column)drv.DataBoundItem;
                if (tmp.IsUser)
                {
                    SelectData.Add(tmp);
                }
            }
            this.DialogResult = DialogResult.OK;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ColumnFrm_Load(object sender, EventArgs e)
        {
            try
            {
                dgvMain.AutoGenerateColumns = false;
                dgvMain.AllowUserToAddRows = false;
                colTxtTblName.DataPropertyName = Column.signName;
                colChkColIsUser.DataPropertyName = Column.signIsUser;
                DbBase dal = DbFactory.GetDbBase();
                List<Column> list = dal.LoadColumns(EditData);
                dgvMain.DataSource = list;
            }
            catch (Exception ex)
            {

            }
        }
    }
}
